<?php
//站点设置ACTION
class WebConfigAction extends BaseAction {
	
	//配置修改
	public function index(){
		$obj = WebConfigHelper::getObject();
		$this->assign("obj",$obj);
		$this->assign("type", 'config');
		$this->display();
	}
	
	//SEO配置修改
	public function seo(){
		$obj = WebConfigHelper::getObject();
		$this->assign("obj",$obj);
		$this->assign("type", 'seo_config');
		$this->display();
	}
	
	//配置修改的处理流
	public function process(){
		
		$data["company_name"] = $this->_post("company_name");
		$data["company_addr"] = $this->_post("company_addr");
		$data["contact_username"] = $this->_post("contact_username");
		$data["telephone"] = $this->_post("telephone");
		$data["mobile"] = $this->_post("mobile");
		$data["fax"] = $this->_post("fax");
		$data["postcode"] = $this->_post("postcode");
		$data["email"] = $this->_post("email");
		$data["footer_cont"] = htmlspecialchars(stripslashes($_POST['footer_cont']));
		$data["footer_js_cont"] = htmlspecialchars(stripslashes($_POST['footer_js_cont']));
		
		$obj4check = WebConfigHelper::getObject();
		$result = false;
		if(empty($obj4check)){	//执行插入
			$result = WebConfigHelper::add($data);
		}else{	//执行更新
			$result = WebConfigHelper::update($data);
		}
		
		if($result === false){	//失败，则提示错误信息，并返回上一个页面[记录了上一个页面，用户填写的信息]
			echo CommonUtil::ajaxReturn(Status::$ERROR,"服务器繁忙，请稍后重试！");
		}else{	//修改成功，提示成功信息，并且返回上一个页面
			echo CommonUtil::ajaxReturn(Status::$SUCCESS,"修改成功！");
		}
		
	}
	
	//SEO修改的处理流
	public function seo_process(){
		
		$data["index_seo_title"] = $this->_post("index_seo_title");
		$data["index_seo_keywords"] = $this->_post("index_seo_keywords");
		$data["index_seo_description"] = $this->_post("index_seo_description");
		
		$obj4check = WebConfigHelper::getObject();
		$result = false;
		if(empty($obj4check)){	//执行插入
			$result = WebConfigHelper::add($data);
		}else{	//执行更新
			$result = WebConfigHelper::update($data);
		}
		
		if($result === false){	//失败，则提示错误信息，并返回上一个页面[记录了上一个页面，用户填写的信息]
			echo CommonUtil::ajaxReturn(Status::$ERROR,"服务器繁忙，请稍后重试！");
		}else{	//修改成功，提示成功信息，并且返回上一个页面
			echo CommonUtil::ajaxReturn(Status::$SUCCESS,"修改成功！");
		}
		
	}
	
	
}